package com.ts.api.module.test.controller;

import com.gitee.apanlh.annotation.viewresolver.RequestParamVo;
import com.gitee.apanlh.web.model.vo.RequestVO;
import com.gitee.apanlh.web.model.vo.ResultVO;
import com.ts.api.module.test.message.ApiTestMessage;
import com.ts.api.module.test.message.ApiTestResultMessage;
import com.ts.api.module.test.service.ApiTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 *  API流程测试
 *
 *  @author Pan
 */
@RestController
@RequestMapping("/test/api")
public class ApiTestServerController {

    @Autowired
    private ApiTestService apiTestService;

    /**
     *  测试下游机构流程
     *
     *  @author Pan
     *  @param  requestVO   请求信息
     *  @return ResultVO
     */
    @RequestMapping("/org")
    public ResultVO<ApiTestResultMessage> org(@RequestParamVo RequestVO requestVO) {
        ApiTestMessage apiTestMessage = apiTestService.getMessage(requestVO);
        ApiTestResultMessage resultMessage = apiTestService.testOrg(apiTestMessage);
        return ResultVO.suc(resultMessage);
    }

    /**
     *  半流程平台测试计划
     *
     *  @param  requestVO   请求信息
     *  @return ResultVO
     */
    @RequestMapping("/plat/v2")
    public ResultVO<ApiTestResultMessage> platV2(@RequestParamVo RequestVO requestVO) {
        ApiTestMessage apiTestMessage = apiTestService.getMessage(requestVO);
        ApiTestResultMessage resultMessage = apiTestService.testPlatV2(apiTestMessage);
        return ResultVO.suc(resultMessage);
    }

    /**
     *  半流程平台测试计划
     *
     *  @param  requestVO   请求信息
     *  @return ResultVO
     */
    @RequestMapping("/plat/v2/pullApply")
    public ResultVO<ApiTestResultMessage> testPlatV2PullApply(@RequestParamVo RequestVO requestVO) {
        ApiTestMessage apiTestMessage = apiTestService.getMessage(requestVO);
        ApiTestResultMessage resultMessage = apiTestService.testPlatV2PullApply(apiTestMessage);
        return ResultVO.suc(resultMessage);
    }

    /**
     *  全流程平台测试计划
     *
     *  @param  requestVO   请求信息
     *  @return ResultVO
     */
    @RequestMapping("/plat/v3")
    public ResultVO<ApiTestResultMessage> platV3(@RequestParamVo RequestVO requestVO) {
        ApiTestMessage apiTestMessage = apiTestService.getMessage(requestVO);
        ApiTestResultMessage resultMessage = apiTestService.testPlatV3(apiTestMessage);
        return ResultVO.suc(resultMessage);
    }

    /**
     *  上游渠道测试计划
     *
     *  @param  requestVO   请求信息
     *  @return ResultVO
     */
    @RequestMapping("/channel/api")
    public ResultVO<ApiTestResultMessage> channelApi(@RequestParamVo RequestVO requestVO) {
        return ResultVO.suc();
    }

    /**
     *  H5联登测试计划
     *  @param requestVO
     *  @return
     */
    @RequestMapping("/channel/h5")
    public ResultVO<ApiTestResultMessage> channelH5(@RequestParamVo RequestVO requestVO) {
        return ResultVO.suc();
    }
}
